#include "tp1107_board.h"
#include "device_parameter.h"
#include "format_conversion.h"

#if (_NETWOK_MODLE_TYPE_ == _TP1107_MODULE_) && (_NETWOK_FUNCTION_ENABLE_)

void Tp1107HexToHexString(uint8_t *pHex, char *pString, uint16_t SizeOfHex)
{
  HexToString(pHex, pString, SizeOfHex);
}

bool Tp1107GetEmissionPower(int *pEmissionPowerOut)
{
  int EmissionPower = GetWirelessModuleEmissionPower();

  if (EmissionPower > 0)
  {
    EmissionPower--;
    if (EmissionPower <= TP1107_MAX_EMISSION_POWER)
    {
      if (pEmissionPowerOut != NULL)
      {
        *pEmissionPowerOut = EmissionPower;
      }

      return true;
    }
  }

  return false;
}

bool Tp1107GetSearchNetworkTimeout(uint8_t *pSearchTimeoutOut)
{
  uint8_t SearchTimeout = GetWirelessModuleSearchNetworkTimeout();

  if ((SearchTimeout >= TP1107_MIX_NETWORK_TIMEOUT) && (SearchTimeout <= TP1107_MAX_NETWORK_TIMEOUT))
  {
    if (pSearchTimeoutOut != NULL)
    {
      *pSearchTimeoutOut = SearchTimeout;
    }

    return true;
  }

  return false;
}

bool Tp1107GetFrequencyRange(uint8_t *pFrequencyRangeOut)
{
  uint8_t FreqRange = GetWirelessModuleFrequencyRange();

  if (FreqRange > 0)
  {
    FreqRange--;
    if ((FreqRange >= TP1107_MIX_FREQUENCY_RANGE) && (FreqRange <= TP1107_MAX_FREQUENCY_RANGE))
    {
      if (pFrequencyRangeOut != NULL)
      {
        *pFrequencyRangeOut = FreqRange;
      }

      return true;
    }
  }

  return false;
}

#endif
